/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package networkrespnse;

import utils.Utils;
/**
 *
 * @author Kvest
 */
public class LoginResponse extends Response
{
    private int srvID;
    private int peopleID;
    private String answer;
    private String GUID;
    private int packetNumber;

    public LoginResponse(byte[] data)
    {
        super(LOGIN_RESPONSE);
        srvID = -1;
        peopleID = -1;
        answer = "";
        GUID = "";
        packetNumber = -1;

        parse(data);
    }

    protected void parse(byte[] data)
    {
        int index;
        byte[] temp = new byte[4];
        for (int i=0;i<4;i++)
        {
                temp[i] = data[i];
        }
        index = 4 + Utils.byteToInt(temp);
        //�������� SrvID - ������ ��������
        for (int i=0;i<4;i++)
        {
                temp[i] = data[index++];
        }
        srvID = Utils.byteToInt(temp);
        //�������� PeopleID - ������ ��������
        for (int i=0;i<4;i++)
        {
                temp[i] = data[index++];
        }
        peopleID = Utils.byteToInt(temp);
        //�������� Answer - ������ ��������
        for (int i=0;i<4;i++)
        {
                temp[i] = data[index++];
        }
        int strSize = Utils.byteToInt(temp);
        temp = new byte[strSize];
        for(int i=0;i<strSize;i++)
        {
                temp[i] = data[index++];
        }
        answer = Utils.byteToString(temp);
        //�������� GUID - ��������� ��������
        strSize = 16;
        temp = new byte[strSize];
        for(int i=0;i<strSize;i++)
        {
                temp[i] = data[index++];
        }
        GUID = new String(temp);
        //�������� PacketNumber - ����� ��������
        temp = new byte[4];
        for (int i=0;i<4;i++)
        {
                temp[i] = data[index++];
        }
        packetNumber = Utils.byteToInt(temp);

        System.gc();
    }

    public int getSrvID()
    {
        return srvID;
    }

    public int getPeopleID()
    {
        return peopleID;
    }

    public String getAnswer()
    {
        return answer;
    }

    public String getGUID()
    {
        return GUID;
    }

    public int getPacketNumber()
    {
        return packetNumber;
    }
}
